<?
    $neighbours = 2;
    $left_neighbours = $this->page - $neighbours;
    if(1 > $left_neighbours) {
        $left_neighbours = 1;
    }

    $right_neighbours = $this->page + $neighbours;
//    var_dump($right_neighbours);
//    exit;
    if($this->pages < $right_neighbours) {
        $right_neighbours = $this->pages;
    }

    $HTMLstr .= '<p>';

    if(1 < $this->page) {
        $HTMLstr .= '<a href="?controller=news&page=1">1</a> ... <a href="?controller=news&page='. ($this->page - 1) .'"><сюда</a> ';
    }

    for ($i=$left_neighbours;$i<=$right_neighbours;$i++) {
        if($i != $this->page) {
            $HTMLstr .= '<a href="?controller=news&page='. $i .'">'. $i .'</a> ';
        } else {
            $HTMLstr .= '<b>'. $i .'</b> ';
        }
    }

    if($this->page < $this->pages) {
        $HTMLstr .= '<a href="?controller=news&page='. ($this->page + 1) .'">туда></a> ... <a href="?controller=news&page='. $this->pages .'">'. $this->pages .'</a>';
    }

    $HTMLstr .= '</p>';